package com.example.ccj.b.c.recycler;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.example.ccj.R;
import com.example.ccj.b.c.custom.adapter.InstallRecyclerAdapter;
import com.example.ccj.b.c.ui.install.SwitchCheckBoxControl;

import java.util.ArrayList;
import java.util.List;

/**
 * 设置界面
 */
public class InstallRecycler extends LinearLayout {
    BaseRecycler<SwitchCheckBoxControl> switchCheckBoxControlBaseRecycler;
    List<SwitchCheckBoxControl> addInstallData = new ArrayList<>();
    InstallRecyclerAdapter installRecyclerAdapter;

    public InstallRecycler(Context context) {
        super(context);
        init();
    }

    public InstallRecycler(Context context,List<SwitchCheckBoxControl> addInstallData) {
        super(context);
        this.addInstallData = addInstallData;
        init();
    }

    public InstallRecycler(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        LinearLayout.inflate(getContext(), R.layout.recycler_install,this);
        switchCheckBoxControlBaseRecycler = findViewById(R.id.recycler_install_rec);
        installRecyclerAdapter = new InstallRecyclerAdapter(addInstallData);
        switchCheckBoxControlBaseRecycler.getRefreshLayout().setEnabled(false);
        switchCheckBoxControlBaseRecycler.setAdapter(addInstallData,installRecyclerAdapter);
    }

    public void setData(List<SwitchCheckBoxControl> addInstallData){
        switchCheckBoxControlBaseRecycler.replaceData(addInstallData);
    }

    public void addData(List<SwitchCheckBoxControl> addInstallData){
        switchCheckBoxControlBaseRecycler.addDatas(addInstallData);
    }

    public void addData(SwitchCheckBoxControl addInstallData){
        switchCheckBoxControlBaseRecycler.addDataOnTail(addInstallData);
    }





}
